Don't place html in alt/title attributes, especially with thumbnails
[lhc/web/wiklou.git] / includes / SpecialNewimages.php
index 8d42f4a..58d434b 100644 (file)
@@ -11,13 +11,13 @@ require_once( 'ImageGallery.php' );
 /**
  *
  */
-function wfSpecialNewimages() {
-       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest,
-              $wgGroupPermissions;
+function wfSpecialNewimages( $par, $specialPage ) {
+       global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgGroupPermissions;
 
        $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
        $dbr =& wfGetDB( DB_SLAVE );
        $sk = $wgUser->getSkin();
+       $shownav = !$specialPage->including();
        $hidebots = $wgRequest->getBool('hidebots',1);
 
        if($hidebots) {
@@ -66,7 +66,12 @@ function wfSpecialNewimages() {
        /** Hardcode this for now. */
        $limit = 48;
 
+       if ( $parval = intval( $par ) )
+               if ( $parval <= $limit && $parval > 0 )
+                       $limit = $parval;
+
        $where = array();
+       $searchpar = '';
        if ( $wpIlMatch != '' ) {
                $nt = Title::newFromUrl( $wpIlMatch );
                if($nt ) {
@@ -74,6 +79,7 @@ function wfSpecialNewimages() {
                        $m = str_replace( '%', "\\%", $m );
                        $m = str_replace( '_', "\\_", $m );
                        $where[] = "LCASE(img_name) LIKE '%{$m}%'";
+                       $searchpar = '&wpIlMatch=' . urlencode( $wpIlMatch );
                }
        }
 
@@ -141,21 +147,24 @@ function wfSpecialNewimages() {
 
        $bydate = wfMsg( 'bydate' );
        $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
-       $text = wfMsg( "imagelisttext",
-               "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
-       $wgOut->addHTML( "<p>{$text}\n</p>" );
+       if ($shownav) {
+               $text = wfMsg( 'imagelisttext', "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
+               $wgOut->addHTML( "<p>{$text}\n</p>" );
+       }
 
        $sub = wfMsg( 'ilsubmit' );
        $titleObj = Title::makeTitle( NS_SPECIAL, 'Newimages' );
-       $action = $titleObj->escapeLocalURL(  "limit={$limit}" );
+       $action = $titleObj->escapeLocalURL();
        if(!$hidebots) {
                $action.='&hidebots=0';
        }
-       $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
-         "{$action}\">" .
-         "<input type='text' size='20' name=\"wpIlMatch\" value=\"" .
-         htmlspecialchars( $wpIlMatch ) . "\" /> " .
-         "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
+       if ($shownav) {
+               $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
+                 "{$action}\">" .
+                 "<input type='text' size='20' name=\"wpIlMatch\" value=\"" .
+                 htmlspecialchars( $wpIlMatch ) . "\" /> " .
+                 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
+       }
        $here = $wgContLang->specialPage( 'Newimages' );
 
        /**
@@ -170,27 +179,29 @@ function wfSpecialNewimages() {
        }
        $now = wfTimestampNow();
        $date = $wgLang->timeanddate( $now );
-       $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'rclistfrom', $date ), 'from='.$now.$botpar );
+       $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'rclistfrom', $date ), 'from='.$now.$botpar.$searchpar );
 
-       $botLink = $sk->makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ? wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ? '0' : '1'));
+       $botLink = $sk->makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ? wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar);
 
        $prevLink = wfMsg( 'prevn', $wgLang->formatNum( $limit ) );
        if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
-               $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar );
+               $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar );
        }
 
        $nextLink = wfMsg( 'nextn', $wgLang->formatNum( $limit ) );
        if( $shownImages > $limit && $lastTimestamp ) {
-               $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar );
+               $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar );
        }
 
        $prevnext = '<p>' . $botLink . ' '. wfMsg( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'</p>';
 
-       $wgOut->addHTML( $prevnext );
+       if ($shownav)
+               $wgOut->addHTML( $prevnext );
 
        if( count( $images ) ) {
                $wgOut->addHTML( $gallery->toHTML() );
-               $wgOut->addHTML( $prevnext );
+               if ($shownav)
+                       $wgOut->addHTML( $prevnext );
        } else {
                $wgOut->addWikiText( wfMsg( 'noimages' ) );
        }